#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>

void handle(int sig)
{
    static int i=0;
    std::cout << "第i次触发" << std::endl;
    i++;
}

int main()
{
    int i = 0;
    signal(2,handle);


    while (true)
    {
        /* code */
        std::cout << "第几次打印" << std::endl;
        i++;
        sleep(1);
    }
}